package com.cefa.edu.dao;

import com.cefa.edu.datasource.DataSource;
import com.cefa.edu.model.EducationLevel;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author huangzehui
 * @date 18-8-2 上午9:07
 */
@Mapper
public interface ScheduledMapper {
    @DataSource("cefaedu")
    // Get SQL string from provider
    //@SelectProvider(type= UserProvider.class, method = "getUserString")
    @Results(id="userMap", value={
            @Result(property = "id", column = "id"),
            @Result(property = "name", column = "name"),
            @Result(property = "level", column = "level"),
            @Result(property = "pId", column = "p_id"),
            @Result(property = "gId", column = "g_id"),
            @Result(property = "gradeDate", column = "grade_date"),

    })
    /**
     *
     * @param id 层级的父级id
     * @param level 层级 1、2、3
     * @return
     */
    @Select("select l.id as id, l.* from cefa_edu_user u left join cefa_edu_user_education_level ul on u.id=ul.user_id  left join \n" +
            "cefa_edu_education_level  l on l.id=ul.level_id  WHERE u.id=#{id}  and l.level=#{level} and ul.status=0")
    List<EducationLevel> getEducationLevel(@Param("id") Integer id, @Param("level") Integer level);
}
